package com.example.mall_springboot_01.products.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mall_springboot_01.products.entity.PmsProduct;
import com.example.mall_springboot_01.products.service.IPmsProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商品信息 前端控制器
 * </p>
 *
 * @author gongxl
 * @since 2021-08-02
 */
@RestController
@RequestMapping("/products/pms-product")
@Slf4j
public class PmsProductController {

    @Autowired
    private IPmsProductService iPmsProductService;
    @RequestMapping("/getPmsProductList")
    public List<PmsProduct> getPmsProductList(){
        return iPmsProductService.list();
    }

    /**
     * 分页查询
     * @return
     */
    @RequestMapping("/getPmsProductListPage")
    public IPage<PmsProduct> getPmsProductListPage(@RequestParam(defaultValue = "1") Integer current,@RequestParam(defaultValue = "5") Integer size){
        IPage<PmsProduct> page = new Page<PmsProduct>(current,size);
        return iPmsProductService.page(page,null);
    }

}

